<?php
session_cache_expire(999999999);
if (!isset($_SESSION)) {
    session_start();
}
include '../../operations/connection.php';

$idboard = $_REQUEST['idboard'];
$action = $_REQUEST['action'];
$newlang = $_REQUEST['newlang'];

if ($_REQUEST['newlang'] == "EN") {
    include "../../value/value_en.php";
} else if ($_REQUEST['newlang'] == "VN") {
    include "../../value/value_vn.php";
} else {
    include "../../value/value_kr.php";
}

if ($action == 'edit') {
    $sqledit = "SELECT * FROM board where ID ='$idboard' ";
    $result = mysql_fetch_assoc(mysql_query($sqledit));
    $title = $result[Title];
    $content = $result[Content];
    $idemployee = $result[IDEmployee];
    $type = $result[Type];
} else {
    $title = "";
    $content = "";
}
?>
<style>
.cke_editor {
display: table;
height: 800px;
}
</style>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"
src="admin/ckeditor_351/ckeditor.js"></script>
<script type="text/javascript"
src="admin/ckfinder/ckfinder.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var editor = CKEDITOR.replace("ncontent",{language:"<?php
$lang_current = $_SESSION['lang'];
if (isset($lang_current)) {
    if ($lang_current == 'VN') {
        echo 'vi';
    } else if ($lang_current == 'KR') {
        echo 'ko';
    } else {
        echo 'en';
    }
} else {
    echo 'en';
}
?>", height:'100%', width:'100%'});
            CKFinder.setupCKEditor(editor, 'admin/ckfinder') ;
        });
        function processDeleteNotice(idboard,idemployee,els)
        {
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
                }
            }
            var lang = '<?= $_SESSION['lang'] ?>';
            xmlhttp.open("GET","admin/employeemanagement/process-delete-general-notice.php?idboard="+idboard+"&idemp="+idemployee+"&newlang="+lang,true);
            xmlhttp.send();

        }
        function processPreviewNotice(idboard,els){
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {

                    document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
			        
                }
            }
            var lang = '<?= $_SESSION['lang'] ?>';
            xmlhttp.open("GET","admin/employeemanagement/preview-general-notice.php?idboard="+idboard+"&newlang="+lang,true);
            xmlhttp.send();
        }
</script>
<div style="margin-left: 5px;height: 972px;">
    <div style="height: 10px;"></div>
    <form action="admin/employeemanagement/process-add-new-notice.php" method="post">
        <input type="hidden" name='idboard' value="<?= $idboard ?>" /> <input
            type="hidden" name='action' value="<?= $action ?>" />
        <div class="navigation-button" style="background-color: #eef1f3;">
            <a href="general-notices-admin.php"><img
                    src="images/back-admin.png" /> </a>
            <div><?php echo $l_back ?></div>
        </div>

        <div class="navigation-button" style="background-color: #eef1f3;">
            <a href=""><input type="submit" name="save" id="save" value=""
                              style="background: url('images/save-admin.png') no-repeat 40px center;
                              width: 100px; height: 30px;border-bottom: none;border-right: none;cursor: pointer;"></a>
            <div><?php echo $l_save ?></div>
        </div>
        <?php if ($action == 'edit') { ?>
            <div class="navigation-button" style="background-color: #eef1f3;">
                <a href="#" onclick="if(confirm('<?php echo $l_confirm_deleteproject ?>')){ processDeleteNotice('<?= $idboard ?>','<?= $idemployee ?>',this);return true;}else{return false;}"><img
                        src="images/trash.gif" /> </a>
                <div><?php echo $l_delete ?></div>
            </div>
        <?php } ?>

        <br style="clear: both" /> <br />


        <table class="new-board" width="100%" cellspacing="5" cellpadding="5">
            <!-- 
            <tr>
                    <td align="right">
                            <table style="width: 350px; padding-right: 60px">
                                    <tr>
            <?php if ($type == "VN") { ?>
                                                    <td><input id="valueradio" type="radio" name="valueradio"
        								value="VN" checked="checked" /> <label> <?php echo $l_vnoffice ?></label>
        							</td>
                                                    <td><input id="valueradio" type="radio" name="valueradio"
        								value="KR" /> <label> <?php echo $l_koreaoffice ?></label></td>
            <?php } else if ($type == "KR") { ?>
                                                    <td><input id="valueradio" type="radio" name="valueradio"
        								value="VN"/> <label> <?php echo $l_vnoffice ?></label>
        							</td>
                                                    <td><input id="valueradio" type="radio" name="valueradio"
        								value="KR"  checked="checked" /> <label> <?php echo $l_koreaoffice ?></label></td>
            <?php } else { ?>
                                                    <td><input id="valueradio" type="radio" name="valueradio"
        								value="VN"/> <label> <?php echo $l_vnoffice ?></label>
        							</td>
                                                    <td><input id="valueradio" type="radio" name="valueradio"
        								value="KR" /> <label> <?php echo $l_koreaoffice ?></label></td>
            <?php } ?>
						</tr>
					</table>
				</td>
			</tr>
			 -->
            <tr>
                <td><?php echo $l_title ?><br /> <input id="title" name="title" type="text"
                                                        value="<?php echo $title ?>" style="width: 100%; height: 19px;" />
                </td>
            </tr>
            <tr>
                <td style="width:100%"><?php echo $l_content ?><br /> <textarea rows="" cols="" id="ncontent"
                                                                                class="ncontent" name="ncontent" style="width: 100%">
                        <?php echo $content ?>
                    </textarea>
                </td>

            </tr>
        </table>
    </form>
</div>
